package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.AnnouncementFile;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface AnnouncementFileMapper extends BaseMapper<AnnouncementFile> {
    
    /**
     * 根据公告ID查找所有相关文件
     */
    @Select("SELECT * FROM announcement_files WHERE announcement_id = #{announcementId}")
    List<AnnouncementFile> findByAnnouncementId(Long announcementId);

    /**
     * 根据公告ID删除所有相关文件记录
     */
    @Delete("DELETE FROM announcement_files WHERE announcement_id = #{announcementId}")
    int deleteByAnnouncementId(Long announcementId);
} 